From 0e60743d140aff66eca6df712f653ee20f5d4ef3 Mon Sep 17 00:00:00 2001
From: Armand Philippot <git@armandphilippot.com>
Date: Tue, 3 Oct 2023 19:36:03 +0200
Subject: refactor(components): rewrite SocialLink component

* replace default label with a label prop
* rename name prop to icon prop
---
 src/pages/projets/[slug].tsx | 37 ++++++++++++++++++++++++++++---------
 1 file changed, 28 insertions(+), 9 deletions(-)

(limited to 'src/pages/projets/[slug].tsx')

diff --git a/src/pages/projets/[slug].tsx b/src/pages/projets/[slug].tsx
index 89891b3..ee86c7b 100644
--- a/src/pages/projets/[slug].tsx
+++ b/src/pages/projets/[slug].tsx
@@ -19,7 +19,6 @@ import {
   type ResponsiveImageProps,
   Sharing,
   SocialLink,
-  type SocialWebsite,
   Spinner,
   type MetaData,
   Heading,
@@ -30,7 +29,6 @@ import styles from '../../styles/pages/project.module.scss';
 import type { NextPageWithLayout, ProjectPreview, Repos } from '../../types';
 import { ROUTES } from '../../utils/constants';
 import {
-  capitalize,
   getSchemaJson,
   getSinglePageSchema,
   getWebPageSchema,
@@ -182,13 +180,34 @@ const ProjectPage: NextPageWithLayout<ProjectPageProps> = ({ project }) => {
    */
   const getReposLinks = (repositories: Repos): JSX.Element[] => {
     const links = [];
-
-    for (const [name, url] of Object.entries(repositories)) {
-      const socialWebsite = capitalize(name) as SocialWebsite;
-      const socialUrl = `https://${name}.com/${url}`;
-
-      links.push(<SocialLink name={socialWebsite} url={socialUrl} />);
-    }
+    const githubLabel = intl.formatMessage({
+      defaultMessage: 'Github profile',
+      description: 'ProjectsPage: Github profile link',
+      id: 'Nx8Jo5',
+    });
+    const gitlabLabel = intl.formatMessage({
+      defaultMessage: 'Gitlab profile',
+      description: 'ProjectsPage: Gitlab profile link',
+      id: 'sECHDg',
+    });
+
+    if (repositories.github)
+      links.push(
+        <SocialLink
+          icon="Github"
+          label={githubLabel}
+          url={repositories.github}
+        />
+      );
+
+    if (repositories.gitlab)
+      links.push(
+        <SocialLink
+          icon="Gitlab"
+          label={gitlabLabel}
+          url={repositories.gitlab}
+        />
+      );
 
     return links;
   };
-- 
cgit v1.2.3

